// 首页登录后的逻辑


/************ 首页登录 **************/
/*
导航栏     请登录
轮播图右侧    请登录
我的易购    请登录

登录前后的转换
*/
const  bannerLogin1 = document.querySelector('.banner_box_rig > .top > .login >.rig ')
const  bannerLogin2 = document.querySelector('.banner_box_rig > .top > .login >.rig1 ')
const id = window.localStorage.getItem('id')
const token = window.localStorage.getItem('token')
const myyigou_loginAPP = document.querySelector('.myyigou_login')
const myyigou_loginDIS = document.querySelector('.myyigou_dis')
const navLoginAPP = document.querySelector('.nav_rig_login')
const navLoginDIS = document.querySelector('.nav_rig_login1')

if(!id){
    bannerLogin1.classList.add('active')
    bannerLogin2.classList.remove('active')
    myyigou_loginAPP.classList.add('active')
    myyigou_loginDIS.classList.remove('active')
    navLoginAPP.classList.add('active')
    navLoginDIS.classList.remove('active')
}

const  bannerLogin = document.querySelector('.banner_box_rig > .top > .login >.rig1 > .top > .xuanran ')


$.ajax({
    url:'http://localhost:8888/users/info?id=' + id,
    headers:{ authorization: 'token'},
}).then(res =>{ 
    // console.log(res)

    bannerLogin.innerText = res.info.nickname
     myyigou_loginDIS.innerText = res.info.nickname
     navLoginDIS.innerText = res.info.nickname

    if(res.code === 401){
    bannerLogin1.classList.add('active')
    bannerLogin2.classList.remove('active')
    myyigou_loginAPP .classList.add('active')
    myyigou_loginDIS.classList.remove('active')
    navLoginAPP.classList.add('active')
    navLoginDIS.classList.remove('active')
    }
    
    if(res.code === 1){
    bannerLogin1.classList.remove('active')
    bannerLogin2.classList.add('active')
    myyigou_loginAPP .classList.remove('active')
    myyigou_loginDIS.classList.add('active')
    navLoginAPP.classList.remove('active')
    navLoginDIS.classList.add('active')
    }
  
})